<template>
	<view class="container">
		<unicloud-db
			ref="udb"
			v-slot:default="{ data, loading, error, options }"
			:options="options"
			collection="uni-id-users,opendb-department,uni-id-roles,hospitals,services"
			field="username,password_secret_version,nickname,gender,status,mobile,mobile_confirmed,email,email_confirmed,avatar,department_id{name},wx_unionid,wx_openid,ali_openid,apple_openid,comment,realname_auth,last_login_date,last_login_ip,token,inviter_uid,my_invite_code,paramedic_profile"
			:where="queryWhere"
			:getone="true"
			:manual="true"
		>
			<view v-if="error">{{ error.message }}</view>
			<view v-else-if="loading"><uni-load-more :contentText="loadMore" status="loading"></uni-load-more></view>
			<view v-else-if="data">
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">存储文档 ID（用户 ID），系统自动生成</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data._id }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户名，不允许重复</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.username }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">密码，加密存储</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.password }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">密码使用的passwordSecret版本</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.password_secret_version }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户昵称</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.nickname }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户性别：0 未知 1 男性 2 女性</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.gender }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户状态：0 正常 1 禁用 2 审核中 3 审核拒绝</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.status }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">手机号码</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.mobile }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">手机号验证状态：0 未验证 1 已验证</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.mobile_confirmed }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">邮箱地址</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.email }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">邮箱验证状态：0 未验证 1 已验证</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.email_confirmed }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">头像地址</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.avatar }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">部门ID</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.department_id }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户角色</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.role }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">微信unionid</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.wx_unionid }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">微信各个平台openid</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.wx_openid }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">app平台微信openid</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.wx_openid.app - plus }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">微信小程序平台openid</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.wx_openid.mp - weixin }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">支付宝平台openid</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.ali_openid }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">苹果登录openid</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.apple_openid }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">备注</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.comment }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">实名认证信息</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户类型：0 个人用户 1 企业用户</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.type }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">认证状态：0 未认证 1 等待认证 2 认证通过 3 认证失败</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.auth_status }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">认证通过时间</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.auth_date }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">真实姓名/企业名称</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.real_name }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">身份证号码/营业执照号码</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.identity }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">身份证正面照 URL</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.id_card_front }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">身份证反面照 URL</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.id_card_back }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">手持身份证照片 URL</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.in_hand }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">营业执照 URL</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.license }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">联系人姓名</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.contact_person }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">联系人手机号码</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.contact_mobile }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">联系人邮箱</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.realname_auth.contact_email }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">注册时间</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.register_date }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">注册时 IP 地址</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.register_ip }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">最后登录时间</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.last_login_date }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">最后登录时 IP 地址</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.last_login_ip }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户token</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.token }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户全部上级邀请者</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.inviter_uid }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">用户自身邀请码</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.my_invite_code }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工信息</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工编号</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.no }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工姓名</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.name }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工出生年月日</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.birthday }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">头像</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.avatar }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工身份证号</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.id_card_no }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工身份证正面</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.id_card_front }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工身份证反面</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.id_card_back }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工身份证发证机关</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.id_card_issue }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工身份证有效期始</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.id_card_start_date }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">护工身份证有效期止</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.id_card_end_date }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">属相</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.zodiac }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">星座</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.constellation }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">籍贯</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.hometown }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">民族</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.clan }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">学历</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.education }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">地址</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.address }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">银行卡照片</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.bank_card }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">开户银行</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.bank }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">银行卡号</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.bank_card_no }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">工作年限</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.working_year }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">体检报告</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.examination }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">背景调查</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.background_checks }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">专业证件</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.certificates }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">自我介绍</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.introduce }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">考核团评语</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.comment }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">服务照片</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.photos }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">陪护内容</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.care_item }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">培训记录</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.training_records }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">排班时间</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.arrangement }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">意向服务医院</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.hospital }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">服务项</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.service }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">评分</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.score }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">打分数</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.score_count }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">标签</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.tags }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">服务类别：0 医院护理 1 到家护理</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.type }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">工作状态：true 上班 false 上班</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.work_status }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">评论平均分</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.av_comment }}</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="4"><div class="grid-content bg-purple">评论总数</div></el-col>
					<el-col :span="16">
						<div class="grid-content bg-purple-light">{{ data.paramedic_profile.sum_comment }}</div>
					</el-col>
				</el-row>
			</view>
		</unicloud-db>
		<view class="btns">
			<button type="primary" @click="handleUpdate">修改</button>
			<button type="warn" class="btn-delete" @click="handleDelete">删除</button>
		</view>
	</view>
</template>

<script>
// 由schema2code生成，包含校验规则和enum静态数据
import { enumConverter } from '../../js_sdk/validator/uni-id-users.js';

export default {
	data() {
		return {
			queryWhere: '',
			loadMore: {
				contentdown: '',
				contentrefresh: '',
				contentnomore: ''
			},
			options: {
				// 将scheme enum 属性静态数据中的value转成text
				...enumConverter
			}
		};
	},
	onLoad(e) {
		this._id = e.id;
	},
	onReady() {
		if (this._id) {
			this.queryWhere = '_id=="' + this._id + '"';
		}
	},
	methods: {
		handleUpdate() {
			// 打开修改页面
			uni.navigateTo({
				url: './edit?id=' + this._id,
				events: {
					// 监听修改页面成功修改数据后, 刷新当前页面数据
					refreshData: () => {
						this.$refs.udb.loadData({
							clear: true
						});
					}
				}
			});
		},
		handleDelete() {
			this.$refs.udb.remove(this._id, {
				success: res => {
					// 删除数据成功后跳转到list页面
					uni.navigateTo({
						url: './list'
					});
				}
			});
		}
	}
};
</script>

<style>
.container {
	padding: 10px;
}

.btns {
	margin-top: 10px;
	display: flex;
	flex-direction: row;
}

.btns button {
	flex: 1;
}

.btn-delete {
	margin-left: 10px;
}
</style>
